Vue.component('comp-button', {
    template: '\
        <div> \
            <div class="button" v-if="myPage === 1"> \
                <button @click="nextStep" :class="getCla()" :disabled="status">下一步</button> \
                <button class="reset" @click="reset()">重置</button> \
            </div> \
            <div class="button" v-if="myPage != 1"> \
                <button @click="nextStep" :class="getCla()" :disabled="status">下一步</button> \
                <button @click="preStep">上一步</button> \
                <button class="reset" @click="reset()">重置</button> \
            </div> \
            <div class="button" v-if="myPage === max"> \
                <button :class="getCla()" :disabled="status">提交</button> \
                <button @click="preStep">上一步</button> \
                <button class="reset" @click="reset()">重置</button> \
            </div> \
        </div>',
    props: {
        value: {
            type: Number
        },
        max: {
            type: Number
        }
    },
    data: function(){
        return {
            myPage: this.value,
            status: true
        }
    },
    methods: {
        nextStep: function(){
            this.myPage++;
        },
        getCla: function(){
            return [
                {
                    'cant': this.status
                }
            ]
        },
        reset: function(){
            bus.$emit('on-reset',this.myPage);
        },
        preStep: function(){
            this.myPage--;
        },
        getStatus: function(page){
            console.log("更该页面，重新获取status,myPage: " + page);
            bus.$emit('on-status',page);
        }
    },
    mounted: function(){
        var _this = this;
        bus.$on('on-checkBack',function(res){
            if(res.success){
                _this.status = false;
            }else{
                _this.status = true;
            }
        });
    },
    watch: {
        value: function (val) {
            this.myPage = val;
        },
        myPage: function(val) {
            this.$parent.page = val;
            this.getStatus(val);
        }
    }
})
